<?php
function kalendorius() {
	$now = getdate(time());
	$time = mktime(0,0,0, $now['mon'], 1, $now['year']);
	$date = getdate($time);
	$dayTotal = cal_days_in_month(0, $date['mon'], $date['year']);
	$ieskom = array("December","January","February","March","April","June","July","August","September","November");
	$keiciam = array("Gruodis","Sausis","Vasaris","Kovas","Balandis","Birželis","Liepa","Rugpjūtis","Rugsėjis","Spalis","Lapkritis");
	$date['month'] = str_replace($ieskom,$keiciam,$date['month']);
	define("MENUO",$date['month']);
	
	$return = '<table>';
	for ($i = 0; $i < 6; $i++) {
		$return .= '<tr>';
		for ($j = 1; $j <= 7; $j++) {
			$dayNum = $j + $i*7 - $date['wday'];
			$return .= '<td';
			if ($dayNum > 0 && $dayNum <= $dayTotal) {
				if ($dayNum == 24) { $return .= ' style="background: red;">'; }
				elseif ($dayNum == $now['mday']) { $return .= ' style="background: #ccc;">'; }
				else { $return .= '>'; }
				$return .= $dayNum;
			}
			else {
				$return .= '>';
			}
			$return .= '</td>';
		}
		$return .= '</tr>';
		if ($dayNum >= $dayTotal && $i != 6)
			break;
	}
	$return .= '</table>';
	return $return;
}
lentele("Kalendorius",kalendorius(),MENUO);
?>